From 41bb0f9f67a85ac8e17d766492f79a2997d3c6e9 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 1 Dec 2025 16:13:43 +0900
Subject: (김준회) 권한관리: 페이지 조회 권한 확인 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/[lng]/evcp/(evcp)/layout.tsx | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

(limited to 'app/[lng]/evcp/(evcp)/layout.tsx')

diff --git a/app/[lng]/evcp/(evcp)/layout.tsx b/app/[lng]/evcp/(evcp)/layout.tsx
index 82b53307..7fe7f3e7 100644
--- a/app/[lng]/evcp/(evcp)/layout.tsx
+++ b/app/[lng]/evcp/(evcp)/layout.tsx
@@ -1,12 +1,40 @@
 import { ReactNode } from 'react';
 import { Header } from '@/components/layout/Header';
 import { SiteFooter } from '@/components/layout/Footer';
+import { getServerSession } from "next-auth";
+import { authOptions } from "@/app/api/auth/[...nextauth]/route";
+import { verifyNonsapPermission } from "@/lib/nonsap/auth-service";
+import { PermissionChecker } from "@/components/common/permission-checker";
+
+export default async function EvcpLayout({ children }: { children: ReactNode }) {
+    const session = await getServerSession(authOptions);
+    
+    let isAuthorized = true;
+    let authMessage = "";
+
+    // Only check permission if user is logged in
+    if (session?.user?.id) {
+        try {
+            const result = await verifyNonsapPermission(
+                parseInt(session.user.id), 
+                ['SEARCH']
+            );
+            isAuthorized = result.authorized;
+            authMessage = result.message || "";
+        } catch (error) {
+            console.error("Permission check failed:", error);
+            // Default to true in case of error to avoid blocking access due to system error
+            // but logic could be changed to false for strict security
+            isAuthorized = true;
+            authMessage = "Permission check error"; 
+        }
+    }
 
-export default function EvcpLayout({ children }: { children: ReactNode }) {
     return (
         <div className="relative flex min-h-svh flex-col bg-background">
         {/* <div className="relative flex min-h-svh flex-col bg-slate-100 "> */}
             <Header />
+            <PermissionChecker authorized={isAuthorized} message={authMessage} />
             <main className="flex flex-1 flex-col">
                 <div className='container-wrapper'>
                         {children}
@@ -15,4 +43,4 @@ export default function EvcpLayout({ children }: { children: ReactNode }) {
             <SiteFooter/>
         </div>
     );
-}
\ No newline at end of file
+}
-- 
cgit v1.2.3

